# -*- coding: utf-8 -*-

import os
try:
    import cPickle as pickle
except ImportError:
    import pickle

import zlib
import time
import robotparser
import urlparse
import csv

import threading
import time

import threading
from time import ctime,sleep
import multiprocessing
import lxml

# def music(func):
#     for i in range(2):
#         print "I was listening to %s. %s" %(func,ctime())
#         sleep(1)
#
# def move(func):
#     for i in range(2):
#         print "I was at the %s! %s" %(func,ctime())
#         sleep(5)
#
# threads = []
# t1 = threading.Thread(target=music,args=(u'爱情买卖',),name='tt1')
# threads.append(t1)
# t2 = threading.Thread(target=move,args=(u'阿凡达',),name='tt2')
# threads.append(t2)
#
# if __name__ == '__main__':
#     for t in threads:
#         t.setDaemon(True)
#         t.start()
#         print t.getName()
#
#     print "all over %s" %ctime()


import multiprocessing
import time

import cookielib
import urllib2

cookies = cookielib.CookieJar()
cookieHandler = urllib2.HTTPCookieProcessor(cookiejar=cookies)
opener = urllib2.build_opener(cookieHandler)
urllib2.install_opener(opener)

request = urllib2.Request("http://www.baidu.com")
urllib2.urlopen(request)
for cookie in cookies:
    print cookie.name, cookie.value

